<?php
/**
 * 部门
 */
require_once("../global.inc.php");

class SysDepartmentClass extends SystemFrameWork{
	/**
	 * 部门对象
	 *
	 * @var obj
	 */
	var $obj_department;
	
	function main(){
		/**
		 * 部门
		 */
		if (!is_object($this->obj_department)){
			require_once ("department.class.php");
			$this->obj_department = new DepartmentClass();
		}
		
		switch($this->_input['action']){
			case "getmembers":
				$this->_getmembers();
				break;
		}
	}
	/**
	 * 列表
	 */
	function _list(){
		//搜索条件
		$condition = 'where department.department_step=1 and department.status=1 order by department.id desc';
		
		//信息列表
		$this->obj_page->pagebarnum(10);
		$this->obj_page->nowindex = $this->_input['curpage']?$this->_input['curpage']:1;
		$department_array = $this->obj_department->listDepartment($condition,$this->obj_page);
		$page_list = $this->obj_page->show(2);
		
		if (is_array($department_array)){
			//审批流程
			$flow_array = include('flow_config.ini.php');
			for ($i=0;$i<count($department_array);$i++){
				//对时间进行格式化
				$department_array[$i]['draft_date'] = @date("Y-m-d",$department_array[$i]['draft_date']);
				
				if ($department_array[$i]['is_submit'] == 0) {
					if ($department_array[$i]['nowflow_id']) {
						//获取审批明细
						$verify_array = $this->obj_department_verify->getDepartmentVerify($department_array[$i]['nowflow_id']);
						$flow_name = $flow_array[$verify_array['verify_flow']]['name'];
						if ($verify_array['verify_status'] == 1) {
							$verify_status = '审批通过';
						}elseif ($verify_array['verify_status'] == 2){
							$verify_status = '<font color=red>审批打回</font>';
						}else{
							$verify_status = '待审批';
						}
					}else {
						$flow_name = '无';
						$verify_status = '未提交';
					}
				}else {
					if ($department_array[$i]['nowflow_id']) {
						//获取审批明细
						$verify_array = $this->obj_department_verify->getDepartmentVerify($department_array[$i]['nowflow_id']);
						$flow_name = $flow_array[$verify_array['verify_flow']]['name'];
						if ($verify_array['verify_status'] == 1) {
							$verify_status = '审批通过';
						}elseif ($verify_array['verify_status'] == 2){
							$verify_status = '<font color=red>审批打回</font>';
						}else{
							$verify_status = '待审批';
						}
					}else {
						$flow_name = '无';
						$verify_status = '已提交';
					}
				}
				$department_array[$i]['flow_name'] = $flow_name;
				$department_array[$i]['verify_status'] = $verify_status;
			}
		}
		
		/**
		 * 页面输出
		 */
		$this->output("user_id", $_SESSION['s_admin']['id']);
		$this->output("curpage", $this->obj_page->nowindex);
		$this->output('department_array',$department_array);
		$this->output('page_list',$page_list);
		$this->output('group_name',$_SESSION['s_admin']['group_name']); //角色
		$this->output('condition',$this->_input);
		$this->showpage('sys_department_apply.list');
	}
	

}
$department = new SysDepartmentClass();
$department->main();
unset($department);
?>